package Servlet;

import Shiti.Userti;
import service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/queryuserservlet")
public class queryuserservlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        int acc= Integer.parseInt(request.getParameter("acc1"));
        Userservice userservice = new Userservice();
        Userti userti=userservice.cha(acc);
       if (userti!=null){
           out.println("acc"+"\t"+"psw"+"\t"+"name");
           response.getWriter().write("<br>");
           out.println(userti.getAcc()+"\t"+userti.getPsw()+"\t"+userti.getName());
       }else {
           out.println("错误");
       }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
